#include <iostream>
#include <string>
#include <cstring>
#include <set>

struct student
{
	std::string name;
	int score;
	student(const std::string& name, int score):name(name), score(score){};
	bool operator<(const student& other)const
	{
		if(other.score == this->score)
			return this->name < other.name;
		else
			return this->score < other.score;
	}
};

struct Compare
{
	bool operator()(const student& other1, const student& other2)const
	{
		return other1.score == other2.score ? other1.name > other2.name : other1.score > other2.score;
	}
};


int main(void)
{
	std::set<student, Compare> students;
	students.insert(student("Tom", 80));
	students.insert(student("Jim", 80));
	students.insert(student("Ted", 90));
//	std::set<student>::reverse_iterator it;
	std::set<student, Compare>::iterator it;
//	for(it = students.rbegin(); it != students.rend(); ++it)
	for(it = students.begin(); it != students.end(); ++it)
	{
		std::cout<<it->name<<" "<<it->score<<std::endl;
	}
	return 0;
}
